Array.classPrototype.join

Instance of

Function

Parameters

[separator = "," /*String*/]

Return value

/*String*/

Description

The join method creates and returns a new string by concatenating all of the elements in an array, separated by commas or a specified separator string. If the array has only one item, then that item will be returned without using the separator.

Example

let elements = ["Fire", "Air", "Water"];
console.write(elements.join());
console.write("\n");
console.write(elements.join(""));
console.write("\n");
console.write(elements.join("-"));

Expected output

Fire,Air,Water
FireAirWater
Fire-Air-Water

This page has text and code adapted from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join
Prose content on this page is available under (CC-BY-SA 2.5).
Code examples on this page and snippets are in the public domain (CC0).